<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改手机主题</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">

    <style>
        .layui-table-cell{  /*最后的pic为字段的field*/
            height: 100%;
            max-width: 100%;
        }
        .uploader-list {
            margin-left: -15px;
        }

        .uploader-list .info {
            position: relative;
            margin-top: -25px;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            height: 25px;
            text-align: center;
            display: none;
        }

        .uploader-list .handle {
            position: relative;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            text-align: right;
            height: 18px;
            margin-bottom: -18px;
            display: none;
        }

        .uploader-list .handle span {
            margin-right: 5px;
        }

        .uploader-list .handle span:hover {
            cursor: pointer;
        }

        .uploader-list .file-iteme {
            margin: 12px 0 0 15px;
            padding: 1px;
            float: left;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改公司信息</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-form-item">
                            <label class="layui-form-label">公司邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="company_email" id="emai" class="layui-input" value="{$data['company_email']}">
                                <input type="hidden" name="id"  id="wid">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-block">
                                <input type="text" name="company_phone" id="phone"  class="layui-input" value="{$data['company_phone']}">

                            </div>
                        </div>

                        <div class="layui-upload" style="margin-left: 32px">
                             <button type="button" class="layui-btn" id="image2" >LOGO</button>
                            <span>上传比例为1:1的图片<a style="color: red">*若重新上传，请在提示上传成功后再点击提交</a></span>
                            <input type="hidden" name="company_logo" id="company_logo" value="{$data['company_logo']}">

                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 88%">
                                    预览图：
                                    <div class="layui-upload-list uploader-list" style="overflow: auto;" id="uploader-list2">
                                <img style="width: 100px;height: 100px;" src="{$data['company_logo']}" id="img1">
                                    </div>
                            </blockquote>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">备案号</label>
                            <div class="layui-input-block">
                                <input type="text" name="company_code" id="code"  class="layui-input"  value="{$data['company_code']}">

                            </div>
                        </div>


                        <div class="layui-form-item layui-layout-admin">
                            <div class="layui-input-block">
                                <div class="layui-inline" style="left: 0;">
                                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="addsubmit">立即提交</button>
                                    <a class="layui-btn layui-btn-primary prex" data-type="prex">返回</a>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set','layedit','upload'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate,
            upload = layui.upload
            ,form = layui.form;


        form.render(null, 'component-form-group');

        laydate.render({
            elem: '#LAY-component-form-group-date'
        });


        //修改提交
        form.on('submit(addsubmit)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            $.ajax({
                url: "{:url('System/editXiuCompany')}",
                type: 'post',
                dataType: 'json',
                data: {data:data.field},

                success: function(data){
                    if (data.code === 0) {
                        layer.msg('修改成功',{icon:1,time:2000},function(){
                            window.location.href = "{:url('System/system')}";
                        });

                    }else if(data.code===1){
                        layer.close(loading);
                        layer.msg(data.msg,{icon:2,time:1000})
                    }
                    else{
                        layer.close(loading);
                        layer.msg(data.code,{icon:2,time:1000})
                    }
                },

            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


        //上传图片

        var uploadInst = upload.render({
            elem: '#image1'
            ,url: "{:url('Common/upload')}"
            ,multiple: false
            ,before: function(obj){
                obj.preview(function (index, file, result) {
                    $('#img').hide();
                    //上传完毕
                    $('#uploader-list1').append(
                        '<div id="" class="file-iteme">' +
                        '<img style="width: 140px;height: 100px;" src=' + result + '>' +
                        '</div>'
                    );
                });
            }
            ,done: function(res){
                //如果上传失败
                if (res.code == 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                if (res.code == 1) {
                    $('#company_logo').val(res.data);
                    return layer.msg(res.msg);
                }
            }
        });


        var $ = layui.$, active = {
            prex:function(){
                layer.confirm('确认取消本次编辑并返回吗？',function(){
                    window.location.href="{:url('System/system')}";
                });
            }

        };

        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $('.prex').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });


</script>


</body>
</html>



